//
//  TSCreateMsgViewController.m
//  chart
//
//  Created by xu on 15/7/29.
//  Copyright (c) 2015年 xu. All rights reserved.
//

#import "TSEditContentController.h"
#import "TSCreateMsgTableView.h"
#import "TSMutipleCheckTableViewController.h"
#import "TSMsgModel.h"
#import "TSMsgContentItemCell.h"
#import "TSMsgDatePickerTextFieldCell.h"
#import "TSPickerViewTextFieldCell.h"
#import "TSMsgModel.h"


@implementation TSEditContentController{
    
}

@synthesize msgId,content,section,textField;

- (void)viewDidLoad
{
    [super viewDidLoad];
 
    [self createTextField];
    [self initLeftButton];
    [self initTitle];
}



-(void)createTextField
{
    float margin = 10;
    float width = [UIScreen mainScreen].applicationFrame.size.width-margin*2;
    float height = 400;
    CGRect rect = CGRectMake(10, 10, width, height);
    textField = [[UITextView alloc] initWithFrame:rect];
    textField.backgroundColor= [UIColor whiteColor];
    textField.textAlignment=NSTextAlignmentLeft;
   // textField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
    [self.view addSubview:textField];
    if(content){
        [textField setText:content];
    }
}
-(void)initLeftButton{
      WS(weakSelf);
    [self leftBarButtonWithTitle:nil barNorImage:[UIImage imageNamed:@"nav_dark_close"] barHltImage:nil action:^{
        if (!weakSelf) {
            return;
        }
        
        [weakSelf dismissViewControllerAnimated:YES completion:nil];
    }];
}

-(void) initTitle{
    self.title =@"内容";
    WS(weakSelf);
    [self rightBarButtonWithTitle:@"保存" barNorImage:nil barHltImage:nil action:^{
        if (!weakSelf) {
            return;
        }
        [weakSelf rightClick];
    }];
    
}

-(void)rightClick
{
    [[NSNotificationCenter defaultCenter] postNotificationName:TSNotification_SaveContentController object:[textField text] userInfo:@{@"section":[NSString stringWithFormat:@"%d",section]}];
    [self dismissViewControllerAnimated:YES completion:nil];

}
- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
